<template>
	<view class="recharge">
		<view class="main">
			<view class="view">
				提现
				<input v-model="data.num" type="number" placeholder="请输入提现金额">
			</view>
		</view>
		<view class="bot" @click="submit">
			提交
		</view>
		<u-popup :round="20" :zIndex="9999" :show="data.show" @close="data.show = false">
			<view class="confirmOrderBottom">
				<view class="top">
					<text></text>
					收款方式
					<image @tap="data.show = false" src="/static/img/index/101.png" mode="widthFix"></image>
				</view>
				<view class="confirmOrderBottom_1">
					<view v-for="(item,index) in paymentChannels.filter(item=>item.value != 'WALLET')" :key="index" class=""
						@tap="data.payChannel = item.value">
						<view class="left">
							<image :src="'/static/img/index/'+item.icon+'.png'" mode="widthFix"></image>
							{{item.name}}
						</view>
						<image
							:src="data.payChannel == item.value?'/static/img/index/49.png':'/static/img/index/52.png'"
							mode="widthFix">
						</image>
					</view>
				</view>
				<view class="bot">
					<view class="left">
						
					</view>
					<view class="right" @tap="pay">
						立即提现
					</view>
				</view>
			</view>
		
		</u-popup>
	</view>
</template>

<script lang="ts" setup>
	import { reactive } from 'vue';
	import { applyWithdraw } from '@/utils/api/shop'
	import { paymentChannels } from '@/utils/index'
	const data = reactive<any>({
		num: 0,
		payChannel: paymentChannels[1].value,
	})
	const pay=()=>{
		data.show = false;
		uni.showLoading({
			title:'加载中...',
			mask:true
		})
		applyWithdraw({data:{amount: data.num, receiveWay: data.payChannel,walletType:'BOND'} }).then((res) => {
			if(res.code == 200){
				uni.showToast({
					title:'申请成功,请等待审核!',
					icon:'none'
				})
				setTimeout(()=>{
					uni.navigateBack()
				},1000)
			}
		}).catch(()=>{
			uni.hideLoading()
		})
	}
	const submit = () => {
		if (!data.num) {
			uni.showToast({
				title: '请输入金额',
				icon: 'none'
			})
			return;
		}
		data.show = true;
		
		
	}
</script>

<style lang="scss">
	.confirmOrderBottom {
		padding: 24rpx 43rpx;
	
		.top {
			display: flex;
			align-items: center;
			justify-content: space-between;
	
			image {
				width: 30rpx;
			}
	
			text {
				width: 30rpx;
			}
	
			font-size: 32rpx;
		}
	
		.bot {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 30rpx;
	
			.left {
				display: flex;
				flex-direction: column;
				font-size: 24rpx;
	
				text {
					margin-top: 10rpx;
					color: #FF263F;
				}
			}
	
			.right {
				width: 190rpx;
				line-height: 80rpx;
				background: #FF263F;
				text-align: center;
				border-radius: 80rpx;
				color: #fff;
	
			}
		}
	}
	
	.confirmOrderBottom_1 {
		>view {
			justify-content: space-between;
			// padding: 37rpx 35rpx;
			background: #fff;
			display: flex;
			align-items: center;
			margin-top: 32rpx;
	
			.left {
				display: flex;
				align-items: center;
	
				image {
					width: 48rpx;
					margin-right: 25rpx;
				}
	
				font-size: 24rpx;
			}
	
			>image {
				width: 36rpx;
			}
		}
	}
	.recharge {
		display: flex;
		flex-direction: column;
		height: 100vh;
		background: #F4F6FA;

		.main {
			flex: 1;
			padding-top: 30rpx;
			view {
				background: #fff;
				font-size: 32rpx;
				border-radius: 24rpx;

				input {
					flex: 1;
					margin-left: 20rpx;
				}

				margin: 0 auto;
				width: 702rpx;
				height: 96rpx;
				display: flex;
				align-items: center;
				padding: 0 32rpx;
			}
		}

		>.bot {
			width: 560rpx;
			background: #FF263F;
			line-height: 80rpx;
			font-size: 32rpx;
			color: #fff;
			margin: 0 auto;
			margin-bottom: 50rpx;
			border-radius: 80rpx;
			background: #FF263F;
			text-align: center;
		}
	}
</style>